package com.ny.utils;

import com.ny.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DatabaseUpdater {
    
    @Autowired
    private UserMapper userMapper;
    
    /**
     * 更新指定用户的邮箱地址
     * @param userId 用户ID
     * @param email 新的邮箱地址
     * @return 更新结果
     */
    public int updateEmail(int userId, String email) {
        try {
            return userMapper.updateEmail(userId, email);
        } catch (Exception e) {
            System.err.println("更新邮箱失败: " + e.getMessage());
            return 0;
        }
    }
}